<?php

class Pdms_standard_model extends CI_Model {
	
	public function __construct() {
		$this->load->database();
	}
	
	//通过id查询
	public function get_by_id($id) {
		$query = $this->db->get_where('standard', array('id' => $id));
		return $query->row_array();
	}
	
	//通过type_code查询
	public function get_by_type($type_code) {
		$query = $this->db->get_where('standard', array('typecode' => $type_code));
		return $query->result_array();
	}
	
	//新增
	public function create() {
	$data = array(
			'code' => $this->input->post('code'),
			'des' => $this->input->post('des'),
			'typecode' => $_POST['type_code']
		);
		
		return $this->db->insert('standard', $data);
	}
	
	//修改
	public function edit ($id) {
		$data = array(
			'des' => $this->input->post('des'),	
			'typecode' => $_POST['type_code']		
		);
		
		$this->db->where('id', $id);
		$this->db->update('standard', $data);
	}
	
	//删除
	public function del ($id) {
		$this->db->delete('standard', array('id' => $id));
		
	}
	
}